using System.Collections;
using UnityEngine;

public class HUD_OutOfScreenTheTarget : MonoBehaviour
{
	public RectTransform tf;

	private Animator AT_Character;

	public void Init(Transform TF_Target)
	{
		AT_Character = ((!TF_Target.name.Contains("Center bone")) ? null : TF_Target.parent.GetComponent<Animator>());
		StartCoroutine(IE_Show(TF_Target));
	}

	private IEnumerator IE_Show(Transform TF_Target)
	{
		while (TF_Target != null)
		{
			Vector2 newPos = Calc.WorldPosToCanvasPos(TF_Target.position);
			newPos = new Vector2((!(newPos.x > 0f)) ? (CanvasList.instance.TF_CanvasList[0].sizeDelta.x * -0.5f) : (CanvasList.instance.TF_CanvasList[0].sizeDelta.x * 0.5f), newPos.y);
			tf.anchoredPosition = newPos;
			tf.localScale = new Vector2((newPos.x > 0f) ? 1 : (-1), 1f);
			if ((AT_Character != null && !AT_Character.enabled) || Calc.IsVisibleCharacterOnScreen(TF_Target.position, -2f))
			{
				break;
			}
			yield return new WaitForFixedUpdate();
		}
		tf.anchoredPosition = new Vector2(0f, -9999f);
		base.gameObject.SetActive(false);
	}
}
